package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Ticket;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IScenicService;
import cn.wolfcode.trip.base.service.ITicketService;
import cn.wolfcode.trip.base.util.JsonResult;
import cn.wolfcode.trip.base.util.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/ticket")
public class TicketController {

    @Autowired
    private ITicketService ticketService;

    @Autowired
    private IScenicService scenicService;

    @RequestMapping("/list")
    public String list(Model model,@ModelAttribute("qo")QueryObject qo){
        model.addAttribute("pageInfo", ticketService.query(qo));
        model.addAttribute("scenicList", scenicService.listAll());
        return "/ticket/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public JsonResult saveOrUpdate(Ticket ticket){
        ticketService.saveOrUpdate(ticket);
        return new JsonResult() ;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public JsonResult delete(Long id){
        if(id != null){
            ticketService.delete(id);
        }
        return new JsonResult() ;
    }

}
